package pers.wq.model;

import java.util.List;
import java.util.Map;

import pers.wq.BaseModel;

public class ClassModel extends BaseModel {
	public ClassModel(){
		super("class");
	}
	
	public List<Map<String,Object>> getAllClass(){
		return this.select("cid,cname", null, null, null);
	}
	
	public static List<Map<String,Object>> getClassStudent(String cid){
		/**
		 * SELECT sname,concat('[',rname,'][',time,']'),score,tname,aname
		 * FROM student,rpt,srpt,attendance,teacher,room
		 * WHERE student.sid=srpt.sid,attendance.aid=srpt.aid,rpt.rptid=srpt.rptid,rpt.tid=teacher.id,room.rid=rpt.rid
		 * */
		return BaseModel.select("cname,sname,concat('[',rname,'][',time,']') as rptname,tname,pname,aname,score", 
				"student,rpt,srpt,attendance,teacher,room,project,class",
				"srpt.sid=student.sid AND attendance.aid=srpt.aid AND srpt.rptid=rpt.rptid AND rpt.tid=teacher.tid AND room.rid=rpt.rid AND rpt.pid=project.pid AND student.cid=class.cid AND student.cid="+cid, 
				"class.cid,student.sid", 
				null);
	}
}
